package com.czxy.dao;

import com.czxy.damain.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface StudentMapper {


    //查询所有
    @Select("select  *  from  student")
    public List<Student> findAll();


    //根据姓名查询
    @Select("select  *  from  student  where studentname like #{studentname}")
    public  List<Student> findName(@Param("studentname") String studentname);


    //删除
    @Delete("delete  from  student  where  sid = #{sid};")
    public  void   delete(@Param("sid")String sid);


    //添加

    //根据 登录名  判断   学生 是否 存在
    @Select("select  *  from  student where  loginname = #{loginname} ")
    public  List<Student> findLoginName(Student student);


    //添加
    @Insert("insert  into  student values (#{sid}, #{loginname}, #{studentname}, #{password}, #{gender}, #{major}, #{birth}, #{telephone}, #{hobby}, #{photo}, #{remark}")
    public  void  insert(Student student);


    //编辑
    @Select("select *  from  student  where  sid = #{sid}")
    public  Student findStudentId(@Param("sid")String sid);

    //检查有没有重名
    @Select("select *  from  student  where  sid != #{sid}  &&  loginname = #{loginname} ")
    public  List<Student> getRNameStudent(Student student);


    //更新数据库数据
    @Update("update student set  loginname = #{loginname}, studentname = #{studentname}, password= #{password} ,gender = #{gender},major=#{major},birth=#{birth} , telephone=#{telephone}, hobby = #{hobby}, photo = #{photo} , remark = #{remark} where sid = #{sid}")
    public  void update(Student student);


    //查询详情
    @Select("select *  from  student  where  sid = #{sid}")
    public List<Student> findStudentById(@Param("sid") String sid);
























}
